package io;

import javax.swing.*;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;


public class OSWDemo {


    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("osw.txt");
        //创建转换流时通常会指定第2个参数来明确字符集，以此来保证跨平台性
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        osw.write("");
        osw.write("");
        System.out.println("写出完毕！");
        osw.close();//关闭高级流时自动关闭低级流

    }
}
